package com.leonzx.base.service.system;

import com.leonzx.base.dao.system.FileOnlineDAO;
import com.leonzx.base.entity.system.FileOnline;
import com.leonzx.base.service.BaseService;
import com.leonzx.base.utils.SQLUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Author:李晓雷
 * @Description:
 * @Date: 18/07/11 14:24
 */
@Service
public class FileOnlineService extends BaseService {
    @Autowired
    private FileOnlineDAO fileOnlineDAO;

    public List<FileOnline> getAllBaseFileOnline(FileOnline fileOnline) {
        Example example = new Example(FileOnline.class);
        Example.Criteria criteria = example.createCriteria();

        if (StringUtils.isNotBlank(fileOnline.getName())) {
            criteria.andLike("name", SQLUtils.like(fileOnline.getName()));
        }

        if (fileOnline.getState() != null) {
            criteria.andEqualTo("state", fileOnline.getState());
        }
        return fileOnlineDAO.selectByExample(example);
    }
}
